package main

import "fmt"

func main()  {
	//pipeline stage函数
	multiply := func(values []int,multiplier int) []int {
		multipliedValues := make([]int,len(values))
		for i,v := range values {
			multipliedValues[i] = v * multiplier
		}
		return multipliedValues
	}

	add := func(values []int,additive int) []int {
		addedValues := make([]int,len(values))
		for i,v := range values {
			addedValues[i] = v + additive
		}
		return addedValues
	}

	ints := []int{1,2,3,4}
	for _,v := range add(multiply(ints,2),1) {
		fmt.Println(v)
	}

	ints := []int{1,2,3,4}
	for _,v := range multiply(add(multiply(ints,2),1),2) {
		fmt.Println(v)
	}


	//将stage转换为以流为导向
	multiply := func(value,multiplier int) int {
		return value * multiplier
	}
	add := func(value,additive int) int {
		return value + additive
	}
	ints := []int{1,2,3,4}
	for _,v := range ints {
		fmt.Println(multiply(add(multiply(v,2),1),2))
	}

}
